<?php

/*

View Pet (view_pet.php)

*/

$rank_check = 1;
$page_title = "View Pet";
include "header.inc.php";

$array = fetch("SELECT * FROM user_pets2 WHERE owner = '$userid' AND adoption = '0' AND id = '$id' AND game = '$game'");
$getPet = fetch("SELECT * FROM pets2 WHERE id = '$array[species]' AND game = '$game'");

$image = "pet_$getPet[id]";

if ($array[wearing] != 0)
{
	$findLook = fetch("SELECT * FROM pet_looks WHERE change_from = '$array[species]' AND item_name = '$array[wearing]'");

	if ($findLook[id])
	{
		$image = "pet2_$findLook[id]";
	}
}

$hunger = $array[hunger];

$hungerLevel = $hungerArray[$hunger];

if (($array[hunger] > 10) OR ($array[hunger] < 0)) { $hungerLevel = "Unknown ($array[hunger])"; }

$percentHealth = ($array[current_hp] / $array[max_hp]) * 100;
if ($percentHealth <= 35)
{
	$healthLine = "<font color=red>$array[current_hp]/$array[max_hp]</font>";
}
if ($percentHealth > 35)
{
	$healthLine = "<font color=orange>$array[current_hp]/$array[max_hp]</font>";
}
if ($percentHealth > 75)
{
	$healthLine = "<font color=green>$array[current_hp]/$array[max_hp]</font>";
}

if ($array[pet_desc])
{
	$petNote[$id] = "<p><font size=-1><i>$array[pet_desc]</i></font></p>";
}

if ($array[attitude] <= 10)
{
	$attitude[$id] = "<font size=-1 color=red><img src=images/attitude/angry.gif align=middle> <b>ANGRY!</b> <img src=images/attitude/angry.gif align=middle></font>";
}
if (($array[attitude] <= 30) AND ($array[attitude] > 10))
{
	$attitude[$id] = "<font size=-1 color=red><img src=images/attitude/sad.gif align=middle> Sad <img src=images/attitude/sad.gif align=middle></font>";
}
if (($array[attitude] <= 60) AND ($array[attitude] > 30))
{
	$attitude[$id] = "<font size=-1 color=blue><img src=images/attitude/bored.gif align=middle> Bored <img src=images/attitude/bored.gif align=middle></font>";
}
if (($array[attitude] <= 90) AND ($array[attitude] > 60))
{
	$attitude[$id] = "<font size=-1 color=green><img src=images/attitude/happy.gif align=middle> Happy! <img src=images/attitude/happy.gif align=middle></font>";
}
if ($array[attitude] > 90)
{
	$attitude[$id] = "<font size=-1 color=green><img src=images/attitude/shappy.gif align=middle> <b>Extremely happy!</b> <img src=images/attitude/shappy.gif align=middle></font>";
}

$nextLevel[$id] = ($array[level] * 50) * $array[level];

ECHO <<<END
$openHTML
<br>
<CENTER><TABLE BGCOLOR="$tableOutline" CELLSPACING=1 CELLPADDING=0 WIDTH=400>
   <tr>
   <td colspan=2 bgcolor=$topAndBottomBG><font color=$topAndBottomText><b>View Pet:</b></font></td></tr>
   <TR>
      <TD BGCOLOR=$middleBG>
         <p>
	<font size=-1>
	Name: $array[name]<br>
	Level: $array[level]<br>
	Experience: $array[experience]<br>
	Next Level: $nextLevel[$id]<br>
	Health: <b>$healthLine</b><br>
	Strength: $array[strength]<br>
	Intelligence: $array[intelligence]<br>
	Speed: $array[speed]<br>
	Defense: $array[defense]<br>
	Hunger: $hungerLevel<Br>
	</font>
	</p>

	<p>
	<font size=-1>
	1-Player Wins: $array[one_p_wins]<br>
	1-Player Loses: $array[one_p_loses]
	</font>
	</p>

	<p>
	<font size=-1>
	<a href=pet_desc.php?game=$game&id=$array[id]>Add/Edit Desc.</a><br>
	<a href=pet_names.php?game=$game&id=$array[id]>Change Name</a><br>
	<a href='release_pet.php?game=$game&id=$array[id]' onClick="if ( !confirm ('Are you sure you want to delete this pet?') ) { return false; }">Release Pet</a>
	</font>
	</p>
      </TD>
      <TD WIDTH=175 BGCOLOR=#FFFFFF>
         <p align=center>
	<img src=$base_url/images/user_images/opg_$game/pets/$image.gif border=1>
	<br><a href=view_pet.php?id=$array[id]&game=$game><b>$array[name]</b> the $getPet[name]!$petNote[$id]</a></P>	<p align=center>$attitude[$id]</p>
      </TD>
   </TR>
</TABLE>
</CENTER>

<form action=makeactive.php?game=$game&pet=$array[id] method=post>
<p align=center><input type=submit value="Make me your active pet!!"></p>
</form>

<p align=center><a href=mypets.php?game=$game>Back to my pets!</a></p>
$closeHTML

END;

?>